home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group97b.txt
/
000135_icon-group-sender _Wed Dec 10 08:15:31 1997.msg
< prev
next >
Wrap
Internet Message Format
|
2000-09-20
|
2KB
Return-Path: <icon-group-sender>
Received: from kingfisher.CS.Arizona.EDU (kingfisher.CS.Arizona.EDU [192.12.69.239])
by baskerville.CS.Arizona.EDU (8.8.7/8.8.7) with SMTP id IAA02934
for <icon-group-addresses@baskerville.CS.Arizona.EDU>; Wed, 10 Dec 1997 08:15:31 -0700 (MST)
Received: by kingfisher.CS.Arizona.EDU (5.65v4.0/1.1.8.2/08Nov94-0446PM)
id AA09574; Wed, 10 Dec 1997 08:15:30 -0700
Date: Tue, 9 Dec 1997 12:50:11 -0800
From: kwalker@premenos.com (Ken Walker)
Message-Id: <199712092050.MAA02602@varda.premenos.com>
To: icon-group@baskerville.CS.Arizona.EDU, turk@ionet.net
Subject: Re: do while
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Md5: UicDfU8TKuatexnNBIVvtw==
Errors-To: icon-group-errors@optima.CS.Arizona.EDU
Status: RO
> Date: Tue, 09 Dec 1997 11:34:40 -0600
> From: "Dr. Louis A. Turk" <turk@ionet.net>
>
> ...
> How do you write a do while control statement in Icon? I need something
> kind of like this:
>
> do {
> ...
> } while line := read(file)
>
> I have tried to use repeat, but cannot seem to figure out how to cause a
> break at the end of file. This one is, I am sure, very simple, but it
> eludes me.
read() fails when it reaches end-of-file. You can provide a break expression
as an alternative and the loop will terminate when read() fails:
procedure main()
local line, file
file := open("temp") | stop("cannot open file")
repeat {
line := read(file) | break
write(line)
}
write("**done**")
end
If you need to break out of multiple nested loops you can use another
break as an argument to the first one.
Ken Walker, kwalker@premenos.com
Premenos Coporation, Concord, Ca. 94520